package com.spring.service.util;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import com.spring.domain.File;

public class FileMapper implements ParameterizedRowMapper<File>{
	 public File mapRow(ResultSet rs, int rowNum) throws SQLException {
		 File obj = new File();
		 obj.setId(rs.getInt("id"));
		 obj.setName(rs.getString("name"));
		 obj.setDescription(rs.getString("description"));
		 obj.setType(rs.getString("type"));
	     return obj;
	    }
	    
	    public static MapSqlParameterSource sqlMap (File obj){
	    	return new MapSqlParameterSource()
					.addValue("name", obj.getName())
					.addValue("description", obj.getDescription())
					.addValue("type", obj.getType())
					.addValue("id", obj.getId());
	    }
}
